package com.joysuch.wwyt.bp.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author ZhaoQiuWei
 * @Date 2022/6/8 15:53
 */
public enum ApiAlarmSubTypeEnum {
    ONEKEY_ALARM(100, "oneKeyAlarm:alarm", "一键报警"),
    STAY_ALARM(101, "stayAlarm", "滞留报警"),
    OVERBOUNDARY_ALARM(102, "overBoundaryAlarm", "越界报警"),
    OVER_NUM(103, "overNum", "超员报警"),
    LACK_NUM(104, "lackNum", "缺员报警"),
    STILL_ALARM(105, "stillAlarm", "静止报警"),
    LEAVE_ALARM(106, "leaveAlarm", "作业人员离开报警"),
    INTRUDE_ALARM(107, "intrudeAlarm", "非作业人员闯入报警"),
    ALARM_SPEED(108, "alarmSpeed", "车辆超速报警"),
    VEHICLE_OVER(109, "vehicleOver", "车辆越界报警"),
    VEHICLE_STAY(110, "vehicleStay", "车辆滞留报警");

    private Integer id;

    private String code;

    private String name;

    public Integer getId() {
        return id;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    ApiAlarmSubTypeEnum(Integer id, String code, String name) {
        this.id = id;
        this.code = code;
        this.name = name;
    }

    private static final Map<String, ApiAlarmSubTypeEnum> lookup = new HashMap<>();

    static {
        for (ApiAlarmSubTypeEnum e : EnumSet.allOf(ApiAlarmSubTypeEnum.class)) {
            lookup.put(e.code, e);
        }
    }

    public static Integer getIdByCode(String code) {
        ApiAlarmSubTypeEnum e = lookup.get(code);
        if (e != null) {
            return e.id;
        }
        return null;
    }

    public static String getNameByCode(String code) {
        ApiAlarmSubTypeEnum e = lookup.get(code);
        if (e != null) {
            return e.name;
        }
        return null;
    }
}
